package lambda.lambda_ideas.base;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 苹果实体类
 *
 * @author code-worker
 * @date 2021/10/03 10:29
 */
public class Apple {
    private String color;
    private Integer weight;

    @Override
    public String toString() {
        return "Apple{" +
                "color='" + color + '\'' +
                ", weight=" + weight +
                '}';
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public static List<Apple> initData(){
        List<Apple> apples = new ArrayList<>();
        Apple apple = new Apple();
        apple.setWeight(100);
        apple.setColor("green");
        apples.add(apple);
        apple = new Apple();
        apple.setWeight(160);
        apple.setColor("red");
        apples.add(apple);
        System.out.println(apples);
        return apples;
    }

    /**
     * task: 判断是否绿苹果
     * @author code-worker
     * @date 2021/10/3 10:40
     * @param apple 苹果
     * @return boolean
     */
    public static boolean isGreenApple(Apple apple){
        return "green".equals(apple.getColor());
    }

    /**
     * task: 判断是否大苹果
     * @author code-worker
     * @date 2021/10/3 10:41
     * @param apple 苹果
     * @return boolean
     */
    public static boolean isHeavyApple(Apple apple){
        return apple.getWeight() > 150;
    }

}
